package com.example.demo.mapper;

import com.example.demo.entity.Majors;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MajorsMapper {

    @Select("select * from majors")
    List<Majors> selectAll();

    @Select("select * from majors where flag=#{flag}")
    Majors selectByFlag(int flag);

    @Select("select * from majors where college=#{college}")
    Majors selectByCollege(String college);

    @Insert("insert into majors(college,majos,createtime,status) values(#{college},#{#major},{createtime},#{status})")
    int add(Majors majors);

    @Delete("delete from majors where flag=#{flag}")
    int delete(int flag);

    @Update("<script>update majors <set><if test=\"college != null and college != '' \">college=#{college},</if>" +
            "<if test=\"major != null and major != '' \">major=#{major},</if>" +
            "<if test='status != null'>status=#{status},</if>createtime=#{createtime}</set> where flag=#{flag}</script>")
    int update(Majors majors);

}
